package Q3;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static int n;
    public static int ret = Integer.MAX_VALUE;
    public static int[] arr;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextInt();
        arr = new int[100];
        Map<Integer, Boolean> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            arr[i] = (i + 1) * (i + 1);
            map.put(arr[i], true);
        }

        if (map.containsKey(n)) {
            System.out.println(1);
        } else {
            dfs(0, 0, 0);
            System.out.println(ret);
        }
    }

    public static void dfs(int index, int sum, int count) {

        if (ret != Integer.MAX_VALUE) {
            return;
        }

        if (sum == n) {
            ret = Math.min(ret, count);
            return;
        }

        if (index == 100) {
            return;
        }

        //选
        dfs(index + 1, sum + arr[index], count + 1);

        //不选
        dfs(index + 1, sum, count);
    }
}
